package naga.x.platform2.channel.egret.support;

import java.util.Map;
import java.util.TreeMap;

import com.alibaba.fastjson.JSON;

import naga.x.platform2.utils.StringUtils;


/**
 * 白鹭充值回调请求参数
 * @author yang.li
 *
 */
public class PayResult {

	// orderId 订单号 uyyf1000jhhkljlhjkhk
	protected String orderId;
	// id 用户id afdafvsavsavsavsav
	protected String id;
	// money 人民币（元） 10
	protected int money;
	// time Unix时间戳 通知的时间，精确到秒
	protected int time;
	// serverId 游戏区服id 游戏调用支付sdk的时候传入的值
	protected int serverId;
	// goodsId 物品id 游戏提供的充值档id
	protected int goodsId;
	// goodsNumber 物品数量 目前固定为1
	protected int goodsNumber;
	// ext 开发者透传参数 原样返回游戏透传的数据
	protected String ext;
	// sign 签名串 详情见签名生成规则
	protected String sign;
	
	public PayResult() {}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public int getServerId() {
		return serverId;
	}

	public void setServerId(int serverId) {
		this.serverId = serverId;
	}

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}

	public int getGoodsNumber() {
		return goodsNumber;
	}

	public void setGoodsNumber(int goodsNumber) {
		this.goodsNumber = goodsNumber;
	}

	public String getExt() {
		return ext;
	}

	public void setExt(String ext) {
		this.ext = ext;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}
	
	public boolean validate() {
		return StringUtils.isNotEmpty(orderId)
				&& StringUtils.isNotEmpty(id)
				&& money > 0;
	}
	
	public Map<String, String> toMap() {
		Map<String, String> map = new TreeMap<String, String>();
		map.put("orderId", orderId);
		map.put("id", id);
		map.put("money", String.valueOf(money));
		map.put("time", String.valueOf(time));
		map.put("serverId", String.valueOf(serverId));
		map.put("goodsId", String.valueOf(goodsId));
		map.put("goodsNumber", String.valueOf(goodsNumber));
		map.put("ext", ext);
		return map;
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

}
